# Create your views here.
# coding: UTF-8
# -*-coding:utf-8 -*-

from django.http import HttpResponse
import os,sys
import mysql
import log


from django.core.context_processors import csrf
from django.shortcuts import render_to_response


def test_post():
    if not request.POST.has_key(strName):
          return ""    
    if request.POST[strName]:
        return request.POST[strName]          
    else:
        return ""

#中文啊
def index(request):
    #mysql.insert('insert into mytest (t_name) values(%s)',['django'])
    
    sql = 'select * from ad_media'
    param = None
    rst = mysql.doSearch(sql, param)
    rst_str = ''
    for obj in rst:
        
        rst_str += str(obj[0]) + str(obj[1]) + str(obj[2]) + str(obj[3]) + str(obj[4]) + '</br>'
    return HttpResponse(rst_str)

def interface(request, t_name):
    param = ''
    try:
        name = request.GET['name']
    except:
        print 'no param'
        log.print_error_log('no_param')
    print name
    mysql.insert('insert into mytest (t_name) values(%s)',[t_name])
    mysql.doSearch('')
    return HttpResponse("Hello, world. You're at the poll index.")

def insert(request):
    param = ''
    try:
        param = request.GET['name']
    except:
        print 'no param'
        log.print_error_log('no_param')
    mysql.insert('insert into mytest (t_name) values(%s)',[param])
    return HttpResponse("insert success name = " + param)




def detail(request, poll_id):
    return HttpResponse("You're looking at poll %s." % poll_id)

def results(request, poll_id):
    return HttpResponse("You're looking at the results of poll %s." % poll_id)

def vote(request, poll_id):
    return HttpResponse("You're voting on poll %s." % poll_id)

